<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
    <div class="layui-tab">
        <ul class="layui-tab-title">

        </ul>
    </div>
    <div style="margin-top: 20px;">
    </div>
    <form class="layui-form" id="admin">
        <input name="id" type="hidden" value="{$data.id}" >

        <div class="layui-form-item">
            <label class="layui-form-label">取暖费</label>
            <div class="layui-input-inline">
                <input value="{$data.qunuanfei}" type="text" name="qunuanfei" class="layui-input"  placeholder="">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">租房费</label>
            <div class="layui-input-inline">
                <input value="{$data.zufangfei}" type="text" name="zufangfei" class="layui-input"  >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">生活补助</label>
            <div class="layui-input-inline">
                <input value="{$data.shenghuobu}" type="text" name="shenghuobu" class="layui-input"  >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">搬家补助</label>
            <div class="layui-input-inline">
                <input value="{$data.banjiabu}" type="text" name="banjiabu" class="layui-input"  >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">其它1</label>
            <div class="layui-input-inline">
                <input value="{$data.qita1}" type="text" name="qita1" class="layui-input"  >
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">年份</label>
            <div class="layui-input-inline">
                <select name="year" lay-filter="first" id="first" lay-filter="aihao">
                    <option value="">=请选择=</option>

                    <option <?php if($data['year']=='2019') echo "selected";?> value="2019">2019</option>
                    <option <?php if($data['year']=='2020') echo "selected";?> value="2020">2020</option>
                    <option <?php if($data['year']=='2021') echo "selected";?> value="2021">2021</option>

                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">总额</label>
            <div class="layui-input-inline">
                <input readonly id="sum" value="{$data.sum}" type="text" name="sum" class="layui-input"  >
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input value="{$data.bz}" type="text" name="bz" class="layui-input"  >
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
        $("input[name=qunuanfei]").blur(function(){
            var value1= $('input[name=qunuanfei]').val();
            var value2= $('input[name=zufangfei]').val();
            var value3= $('input[name=shenghuobu]').val();
            var value4= $('input[name=banjiabu]').val();
            var value5= $('input[name=qita1]').val();
            var sumValue = parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4)+parseFloat(value5);
            if(sumValue>0){
                $('#sum').val(parseInt(sumValue));
            }
            else{
                $('#sum').val(0);
            }

        })

        $("input[name=zufangfei]").blur(function(){
            var value1= $('input[name=qunuanfei]').val();
            var value2= $('input[name=zufangfei]').val();
            var value3= $('input[name=shenghuobu]').val();
            var value4= $('input[name=banjiabu]').val();
            var value5= $('input[name=qita1]').val();
            var sumValue = parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4)+parseFloat(value5);
            if(sumValue>0){
                $('#sum').val(parseInt(sumValue));
            }
            else{
                $('#sum').val(0);
            }

        })

        $("input[name=shenghuobu]").blur(function(){
            var value1= $('input[name=qunuanfei]').val();
            var value2= $('input[name=zufangfei]').val();
            var value3= $('input[name=shenghuobu]').val();
            var value4= $('input[name=banjiabu]').val();
            var value5= $('input[name=qita1]').val();
            var sumValue = parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4)+parseFloat(value5);
            if(sumValue>0){
                $('#sum').val(parseInt(sumValue));
            }
            else{
                $('#sum').val(0);
            }

        })


        $("input[name=banjiabu]").blur(function(){
            var value1= $('input[name=qunuanfei]').val();
            var value2= $('input[name=zufangfei]').val();
            var value3= $('input[name=shenghuobu]').val();
            var value4= $('input[name=banjiabu]').val();
            var value5= $('input[name=qita1]').val();
            var sumValue = parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4)+parseFloat(value5);
            if(sumValue>0){
                $('#sum').val(parseInt(sumValue));
            }
            else{
                $('#sum').val(0);
            }

        })


        $("input[name=qita1]").blur(function(){
            var value1= $('input[name=qunuanfei]').val();
            var value2= $('input[name=zufangfei]').val();
            var value3= $('input[name=shenghuobu]').val();
            var value4= $('input[name=banjiabu]').val();
            var value5= $('input[name=qita1]').val();
            var sumValue = parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4)+parseFloat(value5);
            if(sumValue>0){
                $('#sum').val(parseInt(sumValue));
            }
            else{
                $('#sum').val(0);
            }

        })


    </script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                    $ = layui.jquery,
                    layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script>
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            //常规用法
            laydate.render({
                elem: '#test1'
            });
        })
    </script>
    <script>
        layui.use(['layer', 'form'], function() {
            var layer = layui.layer,
                    $ = layui.jquery,
                    form = layui.form;
            $(window).on('load', function() {
                form.on('submit(admin)', function(data) {
                    $.ajax({
                        url:"{:url('admin/subsidy/edit')}",
                        data:$('#admin').serialize(),
                        type:'post',
                        async: false,
                        success:function(res) {
                            if(res.code == 1) {
                                layer.alert('提交成功！',{icon:6}),

                                        setTimeout(function(){
                                            parent.location.reload();
                                        },1500)
                            }else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                    return false;
                });
            });
        });
    </script>
</div>
</body>
</html>